package xyz.jangle.date;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;

public class DateStrTest {

	public static void main(String[] args) {

//        test1();
		test2();
		
	}
	
	public static void test2() {
		LocalDate today = LocalDate.now(); // 获取当前日期
        LocalDate startDate = today.minusDays(80); // 设置为今天之前的第89天
 
        for (LocalDate date = startDate; !date.isAfter(today); date = date.plusDays(1)) {
//            System.out.println(date);
            // 创建一个 DateTimeFormatter 对象，指定日期格式
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
     
            // 使用 formatter 将 LocalDate 转换为字符串
//            String formattedDate = date.format(formatter);
            String formattedDate = formatter.format(date);
            System.out.println(formattedDate);
        }
	}
	
	public static void test1(){
		SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
		ArrayList<String> dayList = new ArrayList<String>();
      
		Date today = new Date();
	      for(int i=0;i<90;i++) {
	      	Long time = today.getTime() - i*86400000;
	      	System.out.print(time+" : ");
	      	Date dayByI = new Date(time);
	      	String dayByIStr = sdf2.format(dayByI);
	      	System.out.println(dayByIStr);
	      	dayList.add(dayByIStr);
	      }
	      
//	      for(String day:dayList) {
//	    	  System.out.println(day);
//	      }
	}

}
